/*
 * $Id: Globals.h,v 1.3 2005-07-28 08:53:49 bacon Exp $
 */

#ifndef _GLOBALS_H_
#define _GLOBALS_H_

#include <xp/types.h>
#include <xp/macros.h>
#include <xp/net/socket.h>
#include <xp/utl/log.h>
#include <xpp/Exception.h>
#include <xpp/bas/Mutex.h>
#include <xpp/sys/Path.h>
#include "AppEnv.h"
#include "MainApp.h"

using namespace xpp;
using namespace xpp::bas;
using namespace xpp::sys;
using namespace xpp::utl;

#define APP_MODE_BACKGROUND 0
#define APP_MODE_FOREGROUND 1

extern int          app_mode;
extern xp_log_t     app_log;
extern MainApp*     app_main;
extern Mutex        app_main_mutex;
extern Path         app_path;
extern AppEnv       app_env;
extern AppEnvPath   app_env_path;
extern Mutex        app_env_mutex;

#define APP_NAME                      XP_TEXT("app")
#define APP_INI_FILE                  XP_TEXT("app.ini")
#define APP_LOG_FILE                  XP_TEXT("app.log")
#define APP_FILE_PERM                 0600

#define APP_YES                       XP_TEXT("yes")
#define APP_NO                        XP_TEXT("no")
#define APP_GATE_TCP_SERVICE          XP_QUOTE(0)
#define APP_GATE_MAX_CONNECTIONS_MIN  0  // 0 means unlimited, however
#define APP_GATE_MAX_CONNECTIONS_MAX  100
#define APP_GATE_MAX_CONNECTIONS      5
#define APP_GATE_TIMEOUT_MIN          -1  // -1: unlimited
#define APP_GATE_TIMEOUT_MAX          3600000
#define APP_GATE_TIMEOUT              -1
 
#define APP_LOGGING_TARGET_FILE       XP_TEXT("file")
#define APP_LOGGING_TARGET_SYSLOG     XP_TEXT("syslog")
#define APP_LOGGING_TARGET_CONSOLE    XP_TEXT("console")

#define APP_ENV_LOGGING_TARGET        XP_TEXT("MAIN*LOGGING_TARGET")
#define APP_ENV_LOGGING_LEVEL         XP_TEXT("MAIN*LOGGING_LEVEL")

#define APP_ENV_GATE_ENABLE_TCP       XP_TEXT("GATE*ENABLE_TCP")
#define APP_ENV_GATE_TCP_SERVICE      XP_TEXT("GATE*TCP_SERVICE")
#define APP_ENV_GATE_TCP_LOCAL_ONLY   XP_TEXT("GATE*TCP_LOCAL_ONLY")
#define APP_ENV_GATE_MAX_CONNECTIONS  XP_TEXT("GATE*MAX_CONNECTIONS")
#define APP_ENV_GATE_TIMEOUT          XP_TEXT("GATE*TIMEOUT")

#endif
